﻿@{
    ViewBag.Title = "BringIndex";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section Head
{
    @Html.Css("EditForm", "RightSeparateModule", "dp")
    @Html.Js("datepicker")
    <script type="text/javascript">

        $(function () {
            $("#beginTime").datepicker({ picker: "<img class='picker' align='middle' src='../../Images/icons/s.gif' alt=''/>" });
            $("#endTime").datepicker({ picker: "<img class='picker' align='middle' src='../../Images/icons/s.gif' alt=''/>" });
            var mainheight = document.documentElement.clientHeight;
            var mainWidth = document.documentElement.clientWidth - 10;
            var gh = mainheight - 180;
            var option = {
                height: gh,
                width: mainWidth,
                url: '@Url.Action("GetBringList")',
                colModel: [
                     { display: 'ID', name: 'ID', width: 60, sortable: false, align: 'left', hide: true, iskey: true },
                     { display: '物品名称', name: 'Article_ID', width: 120, sortable: false, hide: false, align: 'left' },
                      { display: '规格', name: 'Article_Unit', width: 120, sortable: false, hide: false, align: 'left' },
                     { display: '领取日期', name: 'BringTime', width: 120, sortable: false, hide: false, align: 'left' },
                     { display: '领取数量', name: 'BringCount', width: 80, sortable: false, hide: false, align: 'left' },
                     { display: '领取人工号', name: 'PersonNo', width: 80, sortable: false, hide: false, align: 'left' },
                     { display: '领取人姓名', name: 'PersonName', width: 100, sortable: false, hide: false, align: 'left' }
                //			         { display: '备注', name: 'Remark', width: 180, sortable: false, hide: false, align: 'left' },
               	],
                buttons: [
                            { name: 'Add', displayname: "物品领用", title: "物品领用", bclass: 'add', onpress: toolbarItem_onclick },
                             { name: 'AddData', displayname: "数据录入", title: "数据录入", bclass: 'add', onpress: toolbarItem_onclick },
                            { separator: true }
                         ],
                singleselected: false,
                sortname: "Sequence",
                sortorder: "asc",
                title: false,
                usepager: true,
                page: 1,
                rp: 20,
                rpoption: [10, 15, 20],
                showcheckbox: true,
                selectedonclick: true, //点击行是否选中
                rowbinddata: true
            };
            var instockgrid = $("#bringList").flexigrid(option);
            //新增，删除，修改
            function toolbarItem_onclick(cmd, grid) {
                if (cmd == "Add") {
                    OpenModelWindow('@Url.Action("AddBring")', { width: 800, height: 410, caption: "物品领用",
                        onclose: refresh
                    });
                }
                else if (cmd == "AddData") {
                    OpenModelWindow('@Url.Action("InputIndex")', { width: 800, height: 410, caption: "数据录入",
                        onclose: refresh
                    });
                }

            } // end of toolbarItem_onclick
            $("#btnQuery").bind("click", function () {
                var no = $('#personNo').val() == null ? "" : $('#personNo').val();
                var na = $('#personName').val() == null ? "" : $('#personName').val();
                var ca = $('#cardNo').val() == null ? "" : $('#cardNo').val();
                var be = $('#beginTime').val() == null ? "" : $('#beginTime').val();
                var ed = $('#endTime').val() == null ? "" : $('#endTime').val();
                option.query = no + "," + na + "," + ca + "," + be + "," + ed;
                option.newp = 0;
                $('#bringList').flexOptions(option).flexReload();
            });
            $("#btnPrint").bind("click", function () {
                var no = $('#personNo').val() == null ? "" : $('#personNo').val();
                var na = $('#personName').val() == null ? "" : $('#personName').val();
                var ca = $('#cardNo').val() == null ? "" : $('#cardNo').val();
                var be = $('#beginTime').val() == null ? "" : $('#beginTime').val();
                var ed = $('#endTime').val() == null ? "" : $('#endTime').val();
                var query = no + "," + na + "," + ca + "," + be + "," + ed;

                var strulr = '@Url.Action("PrintPage")?query=' + query;
                var subwin = window.open(strulr, "", "menubar=no,toolbar=no,status=no,resizable=no,scrollbars=yes");
                subwin.moveTo(0, 0);
                subwin.resizeTo(window.screen.availWidth, window.screen.availHeight);
                return false;



            });
            function refresh() {
                $("#bringList").flexOptions(option).flexReload();
            }

        });
    </script>
}
<div id="container">
    <div id="mainContent">
        <div id="title" class="title">
            已领用物品列表</div>
        <div class="title" style="height: 60px;">
            姓 &nbsp;&nbsp;&nbsp; &nbsp; 名： @Html.TextBox("personName")
            工 &nbsp;&nbsp;&nbsp; &nbsp; 号：@Html.TextBox("personNo")
            卡&nbsp;&nbsp;&nbsp; 号： @Html.TextBox("cardNo")
            <br />
            开始日期： @Html.TextBox("beginTime", null, new { @ReadOnly = false, @style = "width:130px" })
            结束日期： @Html.TextBox("endTime",null, new { @ReadOnly = false, @style = "width:130px" })
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <input type="button" value="查询" id="btnQuery" style="width: 62px; height: 23px;" />
            <input type="button" value="打印" id="btnPrint" style="width: 62px; height: 23px;" />
        </div>
        <table id="bringList" style="display: none;">
        </table>
    </div>
</div>
